<?php 
class class_tag extends database
{
		
	function ListSanPhamByTag($MaTag,$start,$limit)
	{
		$this->setQuery('set names utf8');
		$this->Query();

		$sql = 'select s.MaSo, s.TenSanPham, d.TenDanhMuc, n.Username, s.GiaSanPham, dv.TenDonViTinh, s.SoLuong, s.NhaSanXuat, s.HinhAnh, ROUND(s.DiemDanhGia,2) as DiemDanhGia, s.NgayDang, s.PageView, s.HaveTag 
				from chi_tiet_tag c, san_pham s, danh_muc_san_pham d, nguoi_ban n, don_vi_tinh dv
				where c.MaTag='.$MaTag.' and c.MaSanPham = s.MaSo and s.MaDanhMuc = d.MaDanhMuc and s.MaNguoiBan = n.MaSo and s.MaDonViTinh=dv.MaSo and s.TinhTrangDang=1 and s.TinhTrangXoa=0
				order by NgayDang desc limit '.$start.','.$limit;

		$this->setQuery($sql);
		$table = $this->LoadAllRow();
		return $table;		
	}
	
	function CountListSanPhamByTag($MaTag)
	{

		$sql = 'select * 
				from chi_tiet_tag c
				where c.MaTag='.$MaTag;

		$this->setQuery($sql);
		$table = $this->LoadAllRow();
		$num = count($table);
		return $num;
	}

}
?>